package com.rykj.base;

import com.rykj.util.CommonUtil;

import androidx.annotation.StringRes;
import androidx.fragment.app.FragmentActivity;


/**
 * Description: author: jery on 2016/5/6 10:54.
 */
public class LoadingDialogHelper {

    private static final String TAG = "RyLodingDialog";
    private LoadingDialogFragment ryLodingDialog = null;

    public void showLoading(FragmentActivity activity, @StringRes int stringId) {
        showLoading(activity, CommonUtil.getString(stringId));
    }

    public void showLoading(FragmentActivity activity, String string) {
        if (ryLodingDialog == null) {
            ryLodingDialog = LoadingDialogFragment.newInstance();
        }
        ryLodingDialog.showTip(activity.getSupportFragmentManager(), string);
    }

    public void disMiss() {
        try {
            if (ryLodingDialog != null) {
                ryLodingDialog.dismiss();
            }
        } catch (NullPointerException e) {
            e.printStackTrace();
        } catch (IllegalStateException e) {
            e.printStackTrace();
        }
    }
}
